﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using MINERP.DAL.GoodsDelivery;

namespace MINERP.BLL.GoodsDelivery
{
    public class BaseInfoBLL
    {
        private BaseInfoDAL dal = new BaseInfoDAL();

        #region 货运站信息
        /// <summary>
        /// 货运站信息
        /// </summary>
        /// <returns></returns>
        public List<StationInfo> GetStationInfo()
        {
            try
            {
                DataTable dt = dal.GetStationDT();
                List<StationInfo> stations = new List<StationInfo>();
                foreach (DataRow r in dt.Rows)
                {
                    StationInfo s = new StationInfo();
                    s.StationId = Convert.ToInt32(r["StationId"]);
                    s.StationName = r["StationName"].ToString();
                    stations.Add(s);
                }
                return stations;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        #endregion

        #region 货运站信息
        /// <summary>
        /// 货运站信息
        /// </summary>
        /// <returns></returns>
        public List<StationGoodsInfo> GetStationGoodsInfo()
        {
            try
            {
                DataTable dt = dal.GetStationGoodsDT();
                List<StationGoodsInfo> stations = new List<StationGoodsInfo>();
                foreach (DataRow r in dt.Rows)
                {
                    StationGoodsInfo s = new StationGoodsInfo();
                    s.StationGoodsId = Convert.ToInt32(r["stationGoodsId"]);
                    s.StationGoodsNamePhone = r["stationGoodsNamePhone"].ToString();
                    stations.Add(s);
                }
                return stations;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        #endregion

        #region 收货站信息
        /// <summary>
        /// 收货站信息
        /// </summary>
        /// <returns></returns>
        public List<ReceiveStation> GetReceiveStation()
        {
            try
            {
                DataTable dt = dal.GetReceiveStation();
                List<ReceiveStation> stations = new List<ReceiveStation>();
                foreach (DataRow r in dt.Rows)
                {
                    ReceiveStation s = new ReceiveStation();
                    s.ReceiveStationId = Convert.ToInt32(r["ReceiveStationId"]);
                    s.StationNamePhone = r["StationNamePhone"].ToString();
                    stations.Add(s);
                }
                return stations;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        #endregion

        #region 新增客运站信息
        /// <summary>
        /// 新增客运站信息
        /// </summary>
        /// <param name="stationName"></param>
        public void InsertStation(string stationName)
        {
            try
            {
                dal.InsertStation(stationName);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        #endregion

        #region 插入货运站信息
        /// <summary>
        /// 插入货运站信息
        /// </summary>
        /// <param name="stationGoodsNamePhone"></param>
        public void InsertStationGoods(string stationGoodsNamePhone)
        {
            try
            {
                dal.InsertStationGoods(stationGoodsNamePhone);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        #endregion

        #region 插入收货站信息
        /// <summary>
        /// 插入收货站信息
        /// </summary>
        /// <param name="receiveStation"></param>
        public void InsertReceiveStation(string receiveStation)
        {
            try
            {
                dal.InsertReceiveStation(receiveStation);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        #endregion

        #region 删除客运站
        /// <summary>
        /// 删除客运站
        /// </summary>
        /// <param name="stationId"></param>
        public void DelStation(List<int> stationIds)
        {
            try
            {
                dal.DelStation(stationIds);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        #endregion

        #region 删除货运站及其电话
        /// <summary>
        /// 删除货运站及其电话
        /// </summary>
        /// <param name="stationId"></param>
        public void DelStationGoods(List<int> stationGoodsIds)
        {
            try
            {
                dal.DelStationGoods(stationGoodsIds);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        #endregion

        #region 删除收货站及其电话
        /// <summary>
        /// 删除收货站及其电话
        /// </summary>
        /// <param name="receiveStationIds"></param>
        public void DelReceiveStation(List<int> receiveStationIds)
        {
            try
            {
                dal.DelReceiveStation(receiveStationIds);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        #endregion

        //--------------数据结构-------------------
        /// <summary>
        /// 客运站信息
        /// </summary>
        public class StationInfo
        {
            public int StationId { get; set; }
            public string StationName { get; set; }
        }

        /// <summary>
        /// 货运站信息
        /// </summary>
        public class StationGoodsInfo
        {
            public int StationGoodsId { get; set; }
            public string StationGoodsNamePhone { get; set; }
        }

        /// <summary>
        /// 收货站信息
        /// </summary>
        public class ReceiveStation
        {
            public int ReceiveStationId { get; set; }
            public string StationNamePhone { get; set; }
        }
    }
}
